//-----------------------------------------------------------------------------
#ifndef __CSCREEN_H__
#define __CSCREEN_H__
//-----------------------------------------------------------------------------
#include <QWidget>
#include <QList>
#include <QTimer>
#include "CMyDouble.h"
//-----------------------------------------------------------------------------
#define MAX_VALUES                  5
//-----------------------------------------------------------------------------
class CScreen : public QWidget {
    Q_OBJECT
    public:
        CScreen(QWidget *parent = 0);

        void push(const CMyDouble& value);
        CMyDouble pop(void);
        void swap(void);
        void clear(void);
        void setCurrentNumber(CMyDouble currentNumber);
    protected:
        virtual void paintEvent(QPaintEvent *event);
        virtual void resizeEvent(QResizeEvent *event);
    private:
        QList<CMyDouble> values;
        CMyDouble currentNumber;
        bool isOnEdit;
        QRect errRect;
        QRect pileRect;
        QRect promptRect;
        QRect cursorRect;
        QTimer *timer;

        void draw(QPainter *painter, char c, int xOrig, int yOrig);
        void paintErr(QPainter *painter);
        void paintPile(QPainter *painter);
        void paintPrompt(QPainter *painter);
        void paintCursor(QPainter *painter);
    private slots:
        void redrawCursor(void);
};
//-----------------------------------------------------------------------------
#endif // __CSCREEN_H__
